<%--
  Created by IntelliJ IDEA.
  User: asus
  Date: 2021/11/16
  Time: 11:23
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>功能选择</title>
</head>
<body>
<a href="./user_manage">用户管理</a><br>
<a href="./add_user_manage">添加用户</a><br>
<a href="javascript:(0)" style="color: red" onclick="quit()">安全退出</a>
<div id="username-warp"></div>
<div id="lastLogin-warp"></div>
<div id="count-warp"></div>
<div id="online-warp"></div>
</body>
<script src="/demo02_userManage_war/static/js/jquery-3.6.0.js"></script>
<script>
    getUserName();
    function quit() {
        $.post("/demo02_userManage_war/quit", {}, function (res, status) {
            if (status === "success") {
                res = JSON.parse(res);
                if (res.code === "1") {
                    window.location = res.redirect;
                }
            }
        });
    }

    function getUserName() {
        $.get("/demo02_userManage_war/getUsername", function (res, status) {
            if (status === "success") {
                res = JSON.parse(res)
                if (res.code === "0") {
                    window.location = "./"
                }
                document.getElementById("username-warp").innerHTML = "欢迎用户：" + res.name;
                document.getElementById("lastLogin-warp").innerHTML = "最近登陆时间：" + res.lastLogin;
                document.getElementById("count-warp").innerHTML = "网站访问人数：" + res.counts;
                document.getElementById("online-warp").innerHTML = "当前网站在线人员：" + res.onlineList;
            }
        });
    }
</script>
</html>
